package cn.koala.key.receipt.controller;

import cn.koala.key.api.CityApi;
import cn.koala.key.api.KeyManagementApi;
import cn.koala.key.common.feign.FeignUtils;
import cn.koala.key.complaint.entity.dto.CityInfoDTO;
import cn.koala.key.receipt.vo.CityVO;
import cn.seed.common.core.Result;
import cn.seed.common.core.ResultGenerator;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CityController {

    /**
     * @Description: 模糊查询城市信息
     *
     * @param
     * @return Object
     * @throws
     * @exception:
     * @author: 32415
     * @time: 2019/5/7 15:34
     */
    @GetMapping("/cities")
    public Result<List<CityVO>> getCityLike(@RequestParam(required = false) Integer source) {
        if(source == null) {
            source = -1;
        }
        return FeignUtils.getHttpApi(KeyManagementApi.class).getAllCities(source);
    }

    @ApiOperation(value = "获取全部城市")
    @GetMapping("city/cities")
    public Result<List<CityInfoDTO>> listAllCities() {
        return FeignUtils.getHttpApi(CityApi.class).listAllCities();
    }

    @ApiOperation(value = "根据城市名称获取城市ID")
    @GetMapping("/getCityIdByCityName")
    public Result<CityInfoDTO> getCityIdByCityName(@RequestParam String cityName) {
        return FeignUtils.getHttpApi(CityApi.class).getCityIdByCityName(cityName);
    }
}
